import re
import sqlite3
import os
import logging
from django.http import HttpResponse
from django.conf import settings
import json
import random
import threading
import datetime

oozie_home='/export/datamarket/oozie/oozie-4.3.1/bin/'
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',datefmt='%a, %d %b %Y %H:%M:%S')

r_lock = threading.RLock()
def inquiry(request):

	
	
	if request.method == 'POST':
		try:	
			received_json_data=json.loads(request.body.decode().replace("'", "\""))
			logging.info("\n\n\n\t"+str(received_json_data)+"\n\n")
			pageNo=received_json_data['pageNo'] 
			pageNo=int(pageNo)
			#按四个条件查询
			if re.search(r"oozieMission",str(received_json_data)) and received_json_data['oozieMission'].strip() and  re.search(r"erpName",str(received_json_data)) and received_json_data['erpName'].strip() and  re.search(r"jobid",str(received_json_data)) and received_json_data['jobid'].strip() and re.search(r"mission_status",str(received_json_data)) and received_json_data['mission_status'].strip(): 
				oozieMission=received_json_data['oozieMission'].strip() 
				mission_val=received_json_data['oozieMission'].strip()
				erpName=received_json_data['erpName'].strip() 
				erpName_val=received_json_data['erpName'].strip() 
				user_inputErp=erpName_val
				inquiryTypeErp='erpName_val'
				user_inputMission="%"+mission_val+"%"
				inquiryTypeMission='mission_val'
				jobid=received_json_data['jobid'].strip() 
				user_input3=jobid
				inquiryType3='jobid'
				status=received_json_data['mission_status'].strip() 
				user_inputStatus=status
				user_inputStatus=user_inputStatus.split(',')
				user_inputStatus=["'"+i+"'" for i in user_inputStatus]
				user_inputStatus=','.join(user_inputStatus)
				inquiryTypeStatus='status_tmp'
				allResultStrShow=inquiryMain4(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,user_input3,inquiryType3,user_inputStatus,inquiryTypeStatus,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			#按三个条件查询
			elif re.search(r"oozieMission",str(received_json_data)) and received_json_data['oozieMission'].strip() and  re.search(r"erpName",str(received_json_data)) and received_json_data['erpName'].strip() and  re.search(r"jobid",str(received_json_data)) and received_json_data['jobid'].strip(): 
				oozieMission=received_json_data['oozieMission'].strip() 
				mission_val=received_json_data['oozieMission'].strip()
				erpName=received_json_data['erpName'].strip() 
				erpName_val=received_json_data['erpName'].strip() 
				user_inputErp=erpName_val
				inquiryTypeErp='erpName_val'
				user_inputMission="%"+mission_val+"%"
				inquiryTypeMission='mission_val'
				jobid=received_json_data['jobid'].strip() 
				user_input3=jobid
				inquiryType3='jobid'
				allResultStrShow=inquiryMain3(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,user_input3,inquiryType3,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
				
			elif re.search(r"oozieMission",str(received_json_data)) and received_json_data['oozieMission'].strip() and  re.search(r"erpName",str(received_json_data)) and received_json_data['erpName'].strip() and  re.search(r"mission_status",str(received_json_data)) and received_json_data['mission_status'].strip(): 
				oozieMission=received_json_data['oozieMission'].strip() 
				mission_val=received_json_data['oozieMission'].strip()
				erpName=received_json_data['erpName'].strip() 
				erpName_val=received_json_data['erpName'].strip() 
				user_inputErp=erpName_val
				inquiryTypeErp='erpName_val'
				user_inputMission="%"+mission_val+"%"
				inquiryTypeMission='mission_val'
				status=received_json_data['mission_status'].strip() 
				user_inputStatus=status
				user_inputStatus=user_inputStatus.split(',')
				user_inputStatus=["'"+i+"'" for i in user_inputStatus]
				user_inputStatus=','.join(user_inputStatus)
				inquiryTypeStatus='status_tmp'
				allResultStrShow=inquiryStatus3(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,user_inputStatus,inquiryTypeStatus,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			elif re.search(r"jobid",str(received_json_data)) and received_json_data['jobid'].strip() and  re.search(r"erpName",str(received_json_data)) and received_json_data['erpName'].strip() and  re.search(r"mission_status",str(received_json_data)) and received_json_data['mission_status'].strip(): 
				
				jobid=received_json_data['jobid'].strip() 
				erpName=received_json_data['erpName'].strip() 
				erpName_val=received_json_data['erpName'].strip() 
				user_inputErp=erpName_val
				inquiryTypeErp='erpName_val'
				user_inputMission=jobid
				inquiryTypeMission='jobid'
				status=received_json_data['mission_status'].strip() 
				user_inputStatus=status
				user_inputStatus=user_inputStatus.split(',')
				user_inputStatus=["'"+i+"'" for i in user_inputStatus]
				user_inputStatus=','.join(user_inputStatus)
				inquiryTypeStatus='status_tmp'
				allResultStrShow=inquiryStatus3(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,user_inputStatus,inquiryTypeStatus,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			#按两个条件查询
			elif re.search(r"oozieMission",str(received_json_data)) and received_json_data['oozieMission'].strip() and  re.search(r"erpName",str(received_json_data)) and received_json_data['erpName'].strip(): 
				oozieMission=received_json_data['oozieMission'].strip() 
				mission_val=received_json_data['oozieMission'].strip()
				erpName=received_json_data['erpName'].strip() 
				erpName_val=received_json_data['erpName'].strip() 
				user_inputErp=erpName_val
				inquiryTypeErp='erpName_val'
				user_inputMission="%"+mission_val+"%"
				inquiryTypeMission='mission_val'
				allResultStrShow=inquiryMain2(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			elif re.search(r"jobid",str(received_json_data)) and received_json_data['jobid'].strip() and re.search(r"erpName",str(received_json_data)) and received_json_data['erpName'].strip(): 
				jobid=received_json_data['jobid'].strip() 
				user_inputMission=jobid
				inquiryTypeMission='jobid'
				erpName=received_json_data['erpName'].strip() 
				erpName_val=received_json_data['erpName'].strip() 
				user_inputErp=erpName_val
				inquiryTypeErp='erpName_val'

				allResultStrShow=inquiryMain2(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			
			elif re.search(r"oozieMission",str(received_json_data)) and received_json_data['oozieMission'].strip() and re.search(r"jobid",str(received_json_data)) and  received_json_data['jobid'].strip(): 
				jobid=received_json_data['jobid'].strip() 
				user_inputErp=jobid
				inquiryTypeErp='jobid'
				oozieMission=received_json_data['oozieMission'].strip() 
				mission_val=received_json_data['oozieMission'].strip() 
				user_inputMission="%"+mission_val+"%"
				inquiryTypeMission='mission_val'
				allResultStrShow=inquiryMain2(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			#2包含状态
			elif re.search(r"oozieMission",str(received_json_data)) and received_json_data['oozieMission'].strip() and re.search(r"mission_status",str(received_json_data)) and  received_json_data['mission_status'].strip(): 
				status=received_json_data['mission_status'].strip() 
				user_inputStatus=status
				user_inputStatus=user_inputStatus.split(',')
				user_inputStatus=["'"+i+"'" for i in user_inputStatus]
				user_inputStatus=','.join(user_inputStatus)
				inquiryTypeStatus='status_tmp'
				oozieMission=received_json_data['oozieMission'].strip() 
				mission_val=received_json_data['oozieMission'].strip() 
				user_inputMission="%"+mission_val+"%"
				inquiryTypeMission='mission_val'
				allResultStrShow=inquiryMainStatus2(user_inputStatus,inquiryTypeStatus,user_inputMission,inquiryTypeMission,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			elif re.search(r"erpName",str(received_json_data)) and received_json_data['erpName'].strip() and re.search(r"mission_status",str(received_json_data)) and  received_json_data['mission_status'].strip(): 
				status=received_json_data['mission_status'].strip() 
				user_inputStatus=status
				user_inputStatus=user_inputStatus.split(',')
				user_inputStatus=["'"+i+"'" for i in user_inputStatus]
				user_inputStatus=','.join(user_inputStatus)
				inquiryTypeStatus='status_tmp'
				erpName=received_json_data['erpName'].strip() 
				erpName_val=received_json_data['erpName'].strip() 
				user_inputMission=erpName_val
				inquiryTypeMission='erpName_val'
				allResultStrShow=inquiryMainStatus2(user_inputStatus,inquiryTypeStatus,user_inputMission,inquiryTypeMission,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			elif re.search(r"jobid",str(received_json_data)) and received_json_data['jobid'].strip() and re.search(r"mission_status",str(received_json_data)) and  received_json_data['mission_status'].strip(): 
				status=received_json_data['mission_status'].strip() 
				user_inputStatus=status
				user_inputStatus=user_inputStatus.split(',')
				user_inputStatus=["'"+i+"'" for i in user_inputStatus]
				user_inputStatus=','.join(user_inputStatus)
				inquiryTypeStatus='status_tmp'
				jobid=received_json_data['jobid'].strip() 
				user_inputMission=jobid
				inquiryTypeMission='jobid'
				allResultStrShow=inquiryMainStatus2(user_inputStatus,inquiryTypeStatus,user_inputMission,inquiryTypeMission,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
				
			#单个条件
			elif re.search(r"oozieMission",str(received_json_data)) and received_json_data['oozieMission'].strip():
				oozieMission=received_json_data['oozieMission'].strip() 
				mission_val=received_json_data['oozieMission'].strip() 
				user_input="%"+mission_val+"%"
				inquiryType='mission_val'
				allResultStrShow=inquiryMain(user_input,inquiryType,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			elif re.search(r"erpName",str(received_json_data)) and received_json_data['erpName'].strip():
				erpName=received_json_data['erpName'].strip() 
				erpName_val=received_json_data['erpName'].strip() 
				user_input=erpName_val
				inquiryType='erpName_val'
				allResultStrShow=inquiryMain(user_input,inquiryType,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			elif re.search(r"jobid",str(received_json_data)) and received_json_data['jobid'].strip():
				jobid=received_json_data['jobid'].strip() 
				user_input=jobid
				inquiryType='jobid'
				allResultStrShow=inquiryMain(user_input,inquiryType,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			elif re.search(r"mission_status",str(received_json_data)) and received_json_data['mission_status'].strip():
				status=received_json_data['mission_status'].strip() 
				user_inputStatus=status
				user_inputStatus=user_inputStatus.split(',')
				user_inputStatus=["'"+i+"'" for i in user_inputStatus]
				user_inputStatus=','.join(user_inputStatus)
				inquiryTypeStatus='status_tmp'
				allResultStrShow=inquiryStatus(user_inputStatus,inquiryTypeStatus,pageNo)
				return HttpResponse(json.dumps(allResultStrShow,ensure_ascii=False), content_type="application/json;charset=utf-8")
			
			
			
			
			
	
			else:
				return HttpResponse(json.dumps({'result':'请选择任务ID或任务名称或任务负责人或者任务状态查询','code':'2'},ensure_ascii=False), content_type="application/json;charset=utf-8")
		except:
			logging.info('\n\n\n\t输入格式有误\n\n')
			resultError={'result':'请检查格式','code':'1'}
			return HttpResponse(json.dumps(resultError,ensure_ascii=False), content_type="application/json;charset=utf-8")
	else:
		pass
		
def inquiryMain4(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,user_input3,inquiryType3,user_inputStatus,inquiryTypeStatus,pageNo):
	start=datetime.datetime.now()
	user_inputErp=user_inputErp
	inquiryTypeErp=inquiryTypeErp
	user_inputMission=user_inputMission
	inquiryTypeMission=inquiryTypeMission
	user_input3=user_input3
	inquiryType3=inquiryType3
	user_inputStatus=user_inputStatus
	inquiryTypeStatus=inquiryTypeStatus
	db_path = os.path.normpath('/export/datamarket/OozieProperties/oozie_project/db.sqlite3') 
	db = sqlite3.connect(db_path,check_same_thread=False) 
	
	# 通过cursor创建游标
	cursor = db.cursor()
	

	sql_select_status="select mission_val from oozie_configuration" 
	cursor.execute(sql_select_status) 
	dataShow = cursor.fetchall() 
	all_mission_sql="select count(*) from oozie_configuration "
	cursor.execute(all_mission_sql)
	all_mission_count=cursor.fetchall()
	all_mission_count=all_mission_count[0][0]
	allResult=[]
	threadstauts=[]
	for i in range(all_mission_count):
		tstatus = threading.Thread(target=inquiryMainOozieStatus,args=(dataShow,i,allResult,cursor))
		threadstauts.append(tstatus)
	for tstatus in threadstauts:
		tstatus.start()
	for tstatus in threadstauts:
		tstatus.join()

	#符合有求的总条数

	sql_countAll="select count(*) from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeErp+" like '"+user_inputErp+"'and "+inquiryTypeMission+"  like '"+user_inputMission+"' and "+inquiryType3+" like '"+user_input3+"'"
	logging.info(sql_countAll)
	cursor.execute(sql_countAll)
	dataCountAll=cursor.fetchall()
	dataCountAll=dataCountAll[0][0]
	
	#总页数
	if dataCountAll%10==0:
		pageNumAll=int(dataCountAll/10)
	else:
		pageNumAll=int(dataCountAll/10)+1
	
	if pageNo<=pageNumAll and pageNo>=1:
		#每页展示10条信息
		if pageNo==1:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeErp+" like '"+user_inputErp+"'and "+inquiryTypeMission+" like '"+user_inputMission+"' and "+inquiryType3+" like '"+user_input3+"' limit 10"
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeErp+" like '"+user_inputErp+"'and "+inquiryTypeMission+" like '"+user_inputMission+"' and "+inquiryType3+" like '"+user_input3+"' limit 10)"
		else:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeErp+" like '"+user_inputErp+"'and "+inquiryTypeMission+" like '"+user_inputMission+"' and "+inquiryType3+" like '"+user_input3+"' limit "+str(10*(pageNo-1))+",10"
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeErp+" like '"+user_inputErp+"'and "+inquiryTypeMission+" like '"+user_inputMission+"' and "+inquiryType3+" like '"+user_input3+"' limit "+str(10*(pageNo-1))+",10)"
		cursor.execute(sql_cmd)
		dataShow = cursor.fetchall()
		cursor.execute(sql_pageSize)
		pageSize=cursor.fetchall()
		pageSize=pageSize[0][0]
		allResult=[]
		threads=[]
		for i in range(pageSize):
			t = threading.Thread(target=inquiryMainOozie_status,args=(dataShow,i,allResult))
			threads.append(t)
		for t in threads:
			t.start()
		for t in threads:
			t.join()
		cursor.close()
		db.commit()
		db.close()
		logging.info({'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize})
		return {'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize}
	else:
		cursor.close()
		db.commit()
		db.close()
		pageNoResult={'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
		logging.info(pageNoResult)
		return {'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
#3个包含任务状态
def inquiryStatus3(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,user_inputStatus,inquiryTypeStatus,pageNo):
	start=datetime.datetime.now()
	user_inputErp=user_inputErp
	inquiryTypeErp=inquiryTypeErp
	user_inputMission=user_inputMission
	inquiryTypeMission=inquiryTypeMission
	user_inputStatus=user_inputStatus
	inquiryTypeStatus=inquiryTypeStatus
	
	db_path = os.path.normpath('/export/datamarket/OozieProperties/oozie_project/db.sqlite3') 
	db = sqlite3.connect(db_path,check_same_thread=False) 
	
	# 通过cursor创建游标
	cursor = db.cursor()
	

	sql_select_status="select mission_val from oozie_configuration" 
	cursor.execute(sql_select_status) 
	dataShow = cursor.fetchall() 
	all_mission_sql="select count(*) from oozie_configuration "
	cursor.execute(all_mission_sql)
	all_mission_count=cursor.fetchall()
	all_mission_count=all_mission_count[0][0]
	allResult=[]
	threadstauts=[]
	for i in range(all_mission_count):
		tstatus = threading.Thread(target=inquiryMainOozieStatus,args=(dataShow,i,allResult,cursor))
		threadstauts.append(tstatus)
	for tstatus in threadstauts:
		tstatus.start()
	for tstatus in threadstauts:
		tstatus.join()

	#符合有求的总条数

	sql_countAll="select count(*) from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeErp+" like '"+user_inputErp+"'and "+inquiryTypeMission+"  like '"+user_inputMission+"'"
	cursor.execute(sql_countAll)
	dataCountAll=cursor.fetchall()
	dataCountAll=dataCountAll[0][0]
	
	#总页数
	if dataCountAll%10==0:
		pageNumAll=int(dataCountAll/10)
	else:
		pageNumAll=int(dataCountAll/10)+1
	
	if pageNo<=pageNumAll and pageNo>=1:
		#每页展示10条信息
		if pageNo==1:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeErp+" like '"+user_inputErp+"'and "+inquiryTypeMission+" like '"+user_inputMission+"' limit 10"
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeErp+" like '"+user_inputErp+"'and "+inquiryTypeMission+" like '"+user_inputMission+"' limit 10)"
		else:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeErp+" like '"+user_inputErp+"'and "+inquiryTypeMission+" like '"+user_inputMission+"' limit "+str(10*(pageNo-1))+",10"
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeErp+" like '"+user_inputErp+"'and "+inquiryTypeMission+" like '"+user_inputMission+"' limit "+str(10*(pageNo-1))+",10)"
		cursor.execute(sql_cmd)
		dataShow = cursor.fetchall()
		cursor.execute(sql_pageSize)
		pageSize=cursor.fetchall()
		pageSize=pageSize[0][0]
		#allResult=[]
		threads=[]
		for i in range(pageSize):
			t = threading.Thread(target=inquiryMainOozie_status,args=(dataShow,i,allResult))
			threads.append(t)
		for t in threads:
			t.start()
		for t in threads:
			t.join()
		cursor.close()
		db.commit()
		db.close()
		logging.info({'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize})
		return {'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize}
	else:
		cursor.close()
		db.commit()
		db.close()
		pageNoResult={'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
		logging.info(pageNoResult)
		return {'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
#333
def inquiryMain3(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,user_input3,inquiryType3,pageNo):
	start=datetime.datetime.now()
	user_inputErp=user_inputErp
	inquiryTypeErp=inquiryTypeErp
	user_inputMission=user_inputMission
	inquiryTypeMission=inquiryTypeMission
	user_input3=user_input3
	inquiryType3=inquiryType3
	db_path = os.path.normpath('/export/datamarket/OozieProperties/oozie_project/db.sqlite3') 
	db = sqlite3.connect(db_path) 
	
	# 通过cursor创建游标
	cursor = db.cursor()
	
	#符合有求的总条数

	sql_countAll="select count(*) from oozie_configuration where "+inquiryTypeErp+" like '"+user_inputErp+"' and "+inquiryTypeMission+" like '"+user_inputMission+"' and "+inquiryType3+" like '{}'".format(user_input3)
	cursor.execute(sql_countAll)
	dataCountAll=cursor.fetchall()
	dataCountAll=dataCountAll[0][0]
	
	#总页数
	if dataCountAll%10==0:
		pageNumAll=int(dataCountAll/10)
	else:
		pageNumAll=int(dataCountAll/10)+1
	
	if pageNo<=pageNumAll and pageNo>=1:
		#每页展示10条信息
		if pageNo==1:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeErp+" like '"+user_inputErp+"' and "+inquiryTypeMission+" like '"+user_inputMission+"' and "+inquiryType3+" like '{}' limit 10".format(user_input3)
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeErp+" like '"+user_inputErp+"' and "+inquiryTypeMission+" like '"+user_inputMission+"' and "+inquiryType3+" like '{}' limit 10)".format(user_input3)
		else:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeErp+" like '"+user_inputErp+"' and "+inquiryTypeMission+" like '"+user_inputMission+"' and "+inquiryType3+" like '{}'".format(user_input3)+" limit "+str(10*(pageNo-1))+",10"
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeErp+" like '"+user_inputErp+"' and "+inquiryTypeMission+" like '"+user_inputMission+"' and "+inquiryType3+" like '{}'".format(user_input3)+" limit "+str(10*(pageNo-1))+",10)"
		cursor.execute(sql_cmd)
		dataShow = cursor.fetchall()
		cursor.execute(sql_pageSize)
		pageSize=cursor.fetchall()
		pageSize=pageSize[0][0]
		logging.info(pageSize)
		allResult=[]
		threads=[]
		for i in range(pageSize):
			t = threading.Thread(target=inquiryMainOozie,args=(dataShow,i,start,allResult))
			threads.append(t)
		for t in threads:
			t.start()
		for t in threads:
			t.join()
		cursor.close()
		db.commit()
		db.close()
		logging.info({'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize})
		return {'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize}
	else:
		pageNoResult={'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
		logging.info(pageNoResult)
		return {'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
#2个包含任务状态
def inquiryMainStatus2(user_inputStatus,inquiryTypeStatus,user_inputMission,inquiryTypeMission,pageNo):
	start=datetime.datetime.now()
	
	user_inputMission=user_inputMission
	inquiryTypeMission=inquiryTypeMission
	user_inputStatus=user_inputStatus
	inquiryTypeStatus=inquiryTypeStatus
	
	db_path = os.path.normpath('/export/datamarket/OozieProperties/oozie_project/db.sqlite3') 
	db = sqlite3.connect(db_path,check_same_thread=False) 
	
	# 通过cursor创建游标
	cursor = db.cursor()
	
	sql_select_status="select mission_val from oozie_configuration" 
	cursor.execute(sql_select_status) 
	dataShow = cursor.fetchall() 
	all_mission_sql="select count(*) from oozie_configuration "
	cursor.execute(all_mission_sql)
	all_mission_count=cursor.fetchall()
	all_mission_count=all_mission_count[0][0]
	allResult=[]
	threadstauts=[]
	for i in range(all_mission_count):
		tstatus = threading.Thread(target=inquiryMainOozieStatus,args=(dataShow,i,allResult,cursor))
		threadstauts.append(tstatus)
	for tstatus in threadstauts:
		tstatus.start()
	for tstatus in threadstauts:
		tstatus.join()

	#符合有求的总条数

	sql_countAll="select count(*) from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeMission+" like '"+user_inputMission+"'"
	cursor.execute(sql_countAll)
	dataCountAll=cursor.fetchall()
	dataCountAll=dataCountAll[0][0]
	
	#总页数
	if dataCountAll%10==0:
		pageNumAll=int(dataCountAll/10)
	else:
		pageNumAll=int(dataCountAll/10)+1
	
	if pageNo<=pageNumAll and pageNo>=1:
		#每页展示10条信息
		if pageNo==1:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeMission+" like '"+user_inputMission+"' limit 10"
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeMission+" like '"+user_inputMission+"' limit 10)"
		else:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeMission+" like '"+user_inputMission+"' limit "+str(10*(pageNo-1))+",10"
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") and "+inquiryTypeMission+" like '"+user_inputMission+"' limit "+str(10*(pageNo-1))+",10)"
		cursor.execute(sql_cmd)
		dataShow = cursor.fetchall()
		cursor.execute(sql_pageSize)
		pageSize=cursor.fetchall()
		pageSize=pageSize[0][0]
		#allResult=[]
		threads=[]
		for i in range(pageSize):
			t = threading.Thread(target=inquiryMainOozie_status,args=(dataShow,i,allResult))
			threads.append(t)
		for t in threads:
			t.start()
		for t in threads:
			t.join()
		cursor.close()
		db.commit()
		db.close()
		logging.info({'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize})
		return {'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize}
	else:
		cursor.close()
		db.commit()
		db.close()
		pageNoResult={'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
		logging.info(pageNoResult)
		return {'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
#222按任务负责人和任务名称,jobid一起查询
def inquiryMain2(user_inputErp,inquiryTypeErp,user_inputMission,inquiryTypeMission,pageNo):
	start=datetime.datetime.now()
	user_inputErp=user_inputErp
	inquiryTypeErp=inquiryTypeErp
	user_inputMission=user_inputMission
	inquiryTypeMission=inquiryTypeMission
	db_path = os.path.normpath('/export/datamarket/OozieProperties/oozie_project/db.sqlite3') 
	db = sqlite3.connect(db_path) 
	
	# 通过cursor创建游标
	cursor = db.cursor()
	
	#符合有求的总条数

	sql_countAll="select count(*) from oozie_configuration where "+inquiryTypeErp+" like '"+user_inputErp+"' and "+inquiryTypeMission+" like '{}'".format(user_inputMission)
	cursor.execute(sql_countAll)
	dataCountAll=cursor.fetchall()
	dataCountAll=dataCountAll[0][0]
	
	#总页数
	if dataCountAll%10==0:
		pageNumAll=int(dataCountAll/10)
	else:
		pageNumAll=int(dataCountAll/10)+1
	
	if pageNo<=pageNumAll and pageNo>=1:
		#每页展示10条信息
		if pageNo==1:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeErp+" like '"+user_inputErp+"' and "+inquiryTypeMission+" like '{}' limit 10".format(user_inputMission)
			logging.info(sql_cmd)
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeErp+" like '"+user_inputErp+"' and "+inquiryTypeMission+" like '{}' limit 10)".format(user_inputMission)
			logging.info(sql_pageSize)
		else:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeErp+" like '"+user_inputErp+"' and "+inquiryTypeMission+" like '{}' ".format(user_inputMission)+" limit "+str(10*(pageNo-1))+",10"
			logging.info(sql_cmd)
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeErp+" like '"+user_inputErp+"' and "+inquiryTypeMission+" like '{}'".format(user_inputMission)+" limit "+str(10*(pageNo-1))+",10)"
		cursor.execute(sql_cmd)
		dataShow = cursor.fetchall()
		cursor.execute(sql_pageSize)
		pageSize=cursor.fetchall()
		pageSize=pageSize[0][0]
		allResult=[]
		threads=[]
		for i in range(pageSize):
			t = threading.Thread(target=inquiryMainOozie,args=(dataShow,i,start,allResult))
			threads.append(t)
		for t in threads:
			t.start()
		for t in threads:
			t.join()
		cursor.close()
		db.commit()
		db.close()
		logging.info({'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize})
		return {'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize}
	else:
		pageNoResult={'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
		logging.info(pageNoResult)
		return {'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
		
#通过任务负责人和任务名称和jobid查询单个条件
def inquiryMain(user_input,inquiryType,pageNo):
	start=datetime.datetime.now()
	user_input=user_input
	inquiryType=inquiryType
	db_path = os.path.normpath('/export/datamarket/OozieProperties/oozie_project/db.sqlite3') 
	db = sqlite3.connect(db_path) 
	
	# 通过cursor创建游标
	cursor = db.cursor()
	
	#符合有求的总条数

	sql_countAll="select count(*) from oozie_configuration where "+inquiryType+" like '{}'".format(user_input)
	cursor.execute(sql_countAll)
	dataCountAll=cursor.fetchall()
	dataCountAll=dataCountAll[0][0]
	
	#总页数
	if dataCountAll%10==0:
		pageNumAll=int(dataCountAll/10)
	else:
		pageNumAll=int(dataCountAll/10)+1
	
	if pageNo<=pageNumAll and pageNo>=1:
		#每页展示10条信息
		if pageNo==1:
			sql_cmd = "select * from oozie_configuration where "+inquiryType+" like '{}' limit 10".format(user_input)
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryType+" like '{}' limit 10)".format(user_input)
		else:
			sql_cmd = "select * from oozie_configuration where "+inquiryType+" like '{}'".format(user_input)+" limit "+str(10*(pageNo-1))+",10"
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryType+" like '{}'".format(user_input)+" limit "+str(10*(pageNo-1))+",10)"
		cursor.execute(sql_cmd)
		dataShow = cursor.fetchall()
		cursor.execute(sql_pageSize)
		pageSize=cursor.fetchall()
		pageSize=pageSize[0][0]
		allResult=[]
		threads=[]
		for i in range(pageSize):
			t = threading.Thread(target=inquiryMainOozie,args=(dataShow,i,start,allResult))
			threads.append(t)
		for t in threads:
			t.start()
		for t in threads:
			t.join()
		cursor.close()
		db.commit()
		db.close()
		logging.info({'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize})
		return {'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize}
	else:
		pageNoResult={'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
		logging.info(pageNoResult)
		return {'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
def inquiryMainOozie(dataShow,i,start,allResult):
			#dataShow[i]=dataShow
			i=i
			
			start=start
			allResult=allResult
			#通过任务名称查找相关信息
			randomNum=os.popen('echo -n `date +%s%N`').read()
			jobIDinfoFile='jobIDinfoDisplay'+str(randomNum)+str(random.uniform(1, 24))
			jobidFile='jobidDisplay'+str(randomNum)+str(random.uniform(1, 24))
			os.system("oozie jobs -localtime -filter 'name={}' -len 1 > {}".format(dataShow[i][1],jobIDinfoFile))
		
			######os.system("cat jobIDinfo| awk -F ' ' '{print$1}' > jobid")
			######os.system("sed -i '1d' jobid ")
			######os.system("sed -i '1d' jobid ")
			######os.system("sed -i '2d' jobid ")
			######jobid=os.popen("cat jobid").read().strip()
			jobid=jobid=dataShow[i][0]
			#执行时间
			time_val=dataShow[i][2]
			mission_discription=dataShow[i][5]
			#任务名称
			os.system("cat {}".format(jobIDinfoFile)+"| awk -F ' ' '{print$2}' > "+jobidFile)
			os.system("sed -i '1d' {}".format(jobIDinfoFile))
			#mission_val=os.popen("cat jobid").read().strip()
			mission_val=dataShow[i][1]
			#print(mission_val)
			os.system("cat {}".format(jobIDinfoFile)+"| awk -F ' ' '{print$3}' > "+jobidFile)
			os.system("sed -i '1d' {}".format(jobidFile))
			status=dataShow[i][6]
			shellName=dataShow[i][7]
			shellID=dataShow[i][9]
			if status=='禁用':
				status='禁用'
			else:
				status=os.popen("cat {}".format(jobidFile)).read().strip()
				if status=='SUCCEEDED':
					status='成功'
				elif status =='KILLED' or status=='FAILED':
					status='失败'
				elif status=='RUNNING':
					status='执行中'
				elif status=='SUSPENDED':
					status='队列中'
				else:
					status=os.popen("cat {}".format(jobidFile)).read().strip()
			#print(status)
			#os.system("cat jobIDinfo| awk -F 'CST' '{print$1}' | awk -F '-' '{print$6}'> jobid")
			os.system("cat {}".format(jobIDinfoFile)+"| awk -F 'CST' '{print$1}' > "+jobidFile)
			os.system("sed -i '1d' {}".format(jobidFile))
			try:
				startTime=re.findall(r"oozie-root-W(.*)\s+",os.popen("cat {}".format(jobidFile)).read().strip())[0]
				startTime=re.findall(r"-(.*)\s+",startTime)[0].strip()
			except:
				startTime=''
			os.system("cat {}".format(jobIDinfoFile)+"| awk -F 'CST' '{print$2}' > "+jobidFile)
			try:
				endTime=os.popen("cat {}".format(jobidFile)).read().strip()
			except:
				endTime=''
			erpName=dataShow[i][3]
			#获取任务创建时间和下一次执行时间

			os.system("oozie jobs -localtime -filter 'name={}' -len 1 -jobtype coordinator > {}".format(mission_val,jobIDinfoFile))
			os.system("sed -i '1d' {}".format(jobIDinfoFile))
			os.system("sed -i '1d' {}".format(jobIDinfoFile))
			os.system("sed -i '2d' {}".format(jobIDinfoFile))
			try:
				createTime=re.findall(r"CRON(.*?)CST",os.popen("cat {}".format(jobIDinfoFile)).read().strip())[0].strip()
			except:
				createTime=''
			os.system("cat {}".format(jobIDinfoFile)+"| awk -F 'CST' '{print$2}' > "+jobidFile)
			try:
				nextExecTime=os.popen("cat {}".format(jobidFile)).read().strip()
			except:
				nextExecTime=''
			os.remove('{}'.format(jobIDinfoFile))
			os.remove('{}'.format(jobidFile))
			#要展示的信息
			allResultSingle={'jobid':jobid,'mission_val':mission_val,'time_val':time_val,'mission_status':status,'startTime':startTime,'endTime':endTime,'erpName':erpName,'createTime':createTime,'nextExecTime':nextExecTime,'mission_discription':mission_discription,'mission_type':'','shellName':shellName,'shellID':shellID,'auditing_status':'','monitor':'','execMethod':''}
			allResult.append(allResultSingle)		
		
#按任务状态查询
def inquiryStatus(user_inputStatus,inquiryTypeStatus,pageNo):
	user_inputStatus=user_inputStatus
	inquiryTypeStatus=inquiryTypeStatus
	db_path = os.path.normpath('/export/datamarket/OozieProperties/oozie_project/db.sqlite3') 
	db = sqlite3.connect(db_path,check_same_thread=False) 
	
	# 通过cursor创建游标
	cursor = db.cursor()
	

	sql_select_status="select mission_val from oozie_configuration" 
	cursor.execute(sql_select_status) 
	dataShow = cursor.fetchall() 
	all_mission_sql="select count(*) from oozie_configuration "
	cursor.execute(all_mission_sql)
	all_mission_count=cursor.fetchall()
	all_mission_count=all_mission_count[0][0]
	allResult=[]
	threadstauts=[]
	for i in range(all_mission_count):
		tstatus = threading.Thread(target=inquiryMainOozieStatus,args=(dataShow,i,allResult,cursor))
		threadstauts.append(tstatus)
	for tstatus in threadstauts:
		tstatus.start()
	for tstatus in threadstauts:
		tstatus.join()

	#符合有求的总条数

	sql_countAll="select count(*) from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+")"
	cursor.execute(sql_countAll)
	dataCountAll=cursor.fetchall()
	dataCountAll=dataCountAll[0][0]
	
	#总页数
	if dataCountAll%10==0:
		pageNumAll=int(dataCountAll/10)
	else:
		pageNumAll=int(dataCountAll/10)+1
	
	if pageNo<=pageNumAll and pageNo>=1:
		#每页展示10条信息
		if pageNo==1:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") limit 10"
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") limit 10)"
		else:
			sql_cmd = "select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") limit "+str(10*(pageNo-1))+",10"
			sql_pageSize="select count(*) from(select * from oozie_configuration where "+inquiryTypeStatus+" in ("+user_inputStatus+") limit "+str(10*(pageNo-1))+",10)"
		cursor.execute(sql_cmd)
		dataShow = cursor.fetchall()
		cursor.execute(sql_pageSize)
		pageSize=cursor.fetchall()
		pageSize=pageSize[0][0]
		#allResult=[]
		threads=[]
		for i in range(pageSize):
			t = threading.Thread(target=inquiryMainOozie_status,args=(dataShow,i,allResult))
			threads.append(t)
		for t in threads:
			t.start()
		for t in threads:
			t.join()
		cursor.close()
		db.commit()
		db.close()
		logging.info({'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize})
		return {'data':allResult,'code':'0','totalCount':dataCountAll,'totalPageNum':pageNumAll,'currentPage':pageNo,'pageSize':pageSize}
	else:
		cursor.close()
		db.commit()
		db.close()
		pageNoResult={'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
		logging.info(pageNoResult)
		return {'result':'输入页数'+str(pageNo)+' not in (1,'+str(pageNumAll)+')','code':'3'}
	
def inquiryMainOozieStatus(dataShow,i,allResult,cursor):
		i=i
		allResult=allResult
		randomNum=os.popen('echo -n `date +%s%N`').read() 
		jobIDinfoFile='jobIDinfo'+str(randomNum)+str(random.uniform(1, 24)) 
		jobidFile='jobid'+str(randomNum)+str(random.uniform(1, 24)) 
		os.system(oozie_home+"oozie jobs -localtime -filter 'name={}' -jobtype coordinator -len 1 > {}".format(dataShow[i][0],jobIDinfoFile))
		os.system("sed -i '1d' {}".format(jobIDinfoFile)) 
		os.system("cat {}".format(jobIDinfoFile)+" |awk -F ' ' '{print$1}' >"+jobidFile) 
		os.system("sed -i '1d' {}".format(jobidFile))
		os.system("sed -i '2d' {}".format(jobidFile)) 
		
		
		os.system("oozie jobs -localtime -filter 'name={}' -len 1 > {}".format(dataShow[i][0],jobIDinfoFile))
		
		os.system("cat "+jobIDinfoFile+"| awk -F ' ' '{print$3}' > "+jobidFile)
		os.system("sed -i '1d' {}".format(jobidFile))
		status_tmp=os.popen("cat {}".format(jobidFile)).read().strip()
		#修改sqlite中job为
		
		if status_tmp=='SUCCEEDED':
			status_tmp='成功'
		elif status_tmp =='KILLED' or status_tmp=='FAILED':
			status_tmp='失败'
		elif status_tmp=='RUNNING':
			status_tmp='执行中'
		elif status_tmp=='SUSPENDED':
			status_tmp='队列中'
		else:
			status_tmp=os.popen("cat {}".format(jobidFile)).read().strip()
		os.remove("{}".format(jobIDinfoFile)) 
		os.remove("{}".format(jobidFile)) 
		#sql_status_tmp="update oozie_configuration set status_tmp='"+status_tmp+"' where mission_val='{}'".format(dataShow[i][0]) 
		#with r_lock:
		#	cursor.execute(sql_status_tmp) 
		sql_status="select status from oozie_configuration where mission_val='{}'".format(dataShow[i][0])
		with r_lock:
			cursor.execute(sql_status)
			status_original=cursor.fetchall()
			status_original=status_original[0][0]
		if status_original=='禁用':
			sql_status_original="update oozie_configuration set status_tmp='禁用' where mission_val='{}'".format(dataShow[i][0])
			with r_lock:
				cursor.execute(sql_status_original)
		else:
			sql_status_tmp="update oozie_configuration set status_tmp='"+status_tmp+"' where mission_val='{}'".format(dataShow[i][0]) 
			with r_lock:
				cursor.execute(sql_status_tmp)
		logging.info("修改sqlite中任务为"+dataShow[i][0]+"的状态") 
	
def inquiryMainOozie_status(dataShow,i,allResult):
			#dataShow[i]=dataShow
			i=i
			
			
			allResult=allResult
			#通过任务名称查找相关信息
			randomNum=os.popen('echo -n `date +%s%N`').read()
			jobIDinfoFile='jobIDinfoDisplay'+str(randomNum)+str(random.uniform(1, 24))
			jobidFile='jobidDisplay'+str(randomNum)+str(random.uniform(1, 24))
			os.system("oozie jobs -localtime -filter 'name={}' -len 1 > {}".format(dataShow[i][1],jobIDinfoFile))
		
			######os.system("cat jobIDinfo| awk -F ' ' '{print$1}' > jobid")
			######os.system("sed -i '1d' jobid ")
			######os.system("sed -i '1d' jobid ")
			######os.system("sed -i '2d' jobid ")
			######jobid=os.popen("cat jobid").read().strip()
			jobid=jobid=dataShow[i][0]
			mission_val=dataShow[i][1]
			#执行时间
			time_val=dataShow[i][2]
			erpName=dataShow[i][3]
			mission_discription=dataShow[i][5]
			#任务名称
			os.system("cat {}".format(jobIDinfoFile)+"| awk -F ' ' '{print$2}' > "+jobidFile)
			os.system("sed -i '1d' {}".format(jobIDinfoFile))
			#mission_val=os.popen("cat jobid").read().strip()
			
			#print(mission_val)
			os.system("cat {}".format(jobIDinfoFile)+"| awk -F ' ' '{print$3}' > "+jobidFile)
			os.system("sed -i '1d' {}".format(jobidFile))
			status=dataShow[i][6]
			shellName=dataShow[i][7]
			shellID=dataShow[i][9]
			#status_tmp=dataShow[i][8]
			if status=='禁用':
				status_tmp='禁用'
			else:
				status_tmp=dataShow[i][8]
			#print(status)
			#os.system("cat jobIDinfo| awk -F 'CST' '{print$1}' | awk -F '-' '{print$6}'> jobid")
			os.system("cat {}".format(jobIDinfoFile)+"| awk -F 'CST' '{print$1}' > "+jobidFile)
			os.system("sed -i '1d' {}".format(jobidFile))
			try:
				startTime=re.findall(r"oozie-root-W(.*)\s+",os.popen("cat {}".format(jobidFile)).read().strip())[0]
				startTime=re.findall(r"-(.*)\s+",startTime)[0].strip()
			except:
				startTime=''
			os.system("cat {}".format(jobIDinfoFile)+"| awk -F 'CST' '{print$2}' > "+jobidFile)
			try:
				endTime=os.popen("cat {}".format(jobidFile)).read().strip()
			except:
				endTime=''
			
			#获取任务创建时间和下一次执行时间

			os.system("oozie jobs -localtime -filter 'name={}' -len 1 -jobtype coordinator > {}".format(mission_val,jobIDinfoFile))
			os.system("sed -i '1d' {}".format(jobIDinfoFile))
			os.system("sed -i '1d' {}".format(jobIDinfoFile))
			os.system("sed -i '2d' {}".format(jobIDinfoFile))
			try:
				createTime=re.findall(r"CRON(.*?)CST",os.popen("cat {}".format(jobIDinfoFile)).read().strip())[0].strip()
			except:
				createTime=''
			os.system("cat {}".format(jobIDinfoFile)+"| awk -F 'CST' '{print$2}' > "+jobidFile)
			try:
				nextExecTime=os.popen("cat {}".format(jobidFile)).read().strip()
			except:
				nextExecTime=''
			os.remove('{}'.format(jobIDinfoFile))
			os.remove('{}'.format(jobidFile))
			#要展示的信息
			allResultSingle={'jobid':jobid,'mission_val':mission_val,'time_val':time_val,'mission_status':status_tmp,'startTime':startTime,'endTime':endTime,'erpName':erpName,'createTime':createTime,'nextExecTime':nextExecTime,'mission_discription':mission_discription,'mission_type':'','shellName':shellName,'shellID':shellID,'auditing_status':'','monitor':'','execMethod':''}
			allResult.append(allResultSingle)
